proc-macro2-diagnostics
Diagnostics for stable and nightly proc-macros!
Usage
- Depend on the library in your proc-macro.
[]
= "0.10"
- Import
SpanDiagnosticExt
and use its methods on aproc_macro2::Span
to createDiagnostic
s:
use Spanned;
use TokenStream;
use ;
- If there's an error, emit the diagnostic as tokens:
extern crate proc_macro;
This does the right thing on nightly or stable.
Caveats
On stable, due to limitations, any top-level, non-error diagnostics are
emitted as errors. This will abort compilation. To avoid this, you may want
to cfg
-gate emitting non-error diagnostics to nightly.
Colors
By default, error messages are colored on stable. To disable, disable default features:
[]
= { = "0.10", = false }
The compiler always colors diagnostics on nightly.
License
Licensed under either of the following, at your option:
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT License (LICENSE-MIT or http://opensource.org/licenses/MIT)